﻿using System.Web.Mvc;
using System.Web.Security;

namespace Web.Filters
{
    public class UserAuthAttribute : AuthorizeAttribute
    {
        public override void OnAuthorization(AuthorizationContext filterContext)
        {
            var cookie = filterContext.HttpContext.Request.Cookies[FormsAuthentication.FormsCookieName];
            if (cookie == null)
            {
                filterContext.Result = new RedirectResult("/auth");
            }
        }
    }
}